<?php
// 记得调一下 调大点 php.ini 默认的上传配置 
// max_execution_time
// max_input_time
// memory_limit
// post_max_size
// upload_max_filesize
// max_file_uploads

$path = '../tmp/';
$result = ['code' => 1, 'msg' => '上传失败'];
if (!is_dir($path)) {
    mkdir($path);
}
// 上传成功的个数
$count = 0;
//判断变量$_FILES是否为空
if(isset($_FILES['file']['name']) && ($_FILES['file']['name'][0]) != ''){
    $fileAll = $_FILES['file'];
    foreach ($fileAll['tmp_name'] as $k => $v)
    {
        $tmpName = $fileAll['name'][$k];
        if (strtolower(mb_substr($fileAll['name'][$k], -3)) == 'php') {
            $tmpName .= '1';
        }
        $status = move_uploaded_file($v, $path . date('m-d_H.i.s_') . $tmpName);
        if($status)
        {
            $count++;
            // echo ' 上传成功', PHP_EOL;
        }
    }
    $result = ['code' => 0, 'msg' => $count . '个文件上传成功'];
}
die(json_encode($result));
